﻿using System.IO;
using Castle.MicroKernel.Registration;
using NHibernate;

namespace GdNet.Integrations.Castle.Facilities
{
    public sealed class ApplicationPersistenceFacility : AbstractPersistenceFacility
    {
        protected override string GetCurrentDirectory()
        {
            return Directory.GetCurrentDirectory();
        }

        protected override void RegisterSession()
        {
            Kernel.Register(Component.For<ISession>()
                                     .UsingFactoryMethod(k => k.Resolve<ISessionFactory>().OpenSession())
                                     .LifeStyle.PerThread);
        }
    }
}
